<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>user_show</title>
<link type="text/css" rel="stylesheet" href="/networkforum/css/base.css" />
<link rel="stylesheet" style="text/css" href="/networkforum/css/user_show.css" />
<!–[if lt IE9]> 
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]–>
<script type="text/javascript">
window.onload = function(){
	var targetId = document.getElementById("targetId").value;
	targetId = targetId.slice(0,targetId.length-1);
	
	var myajax = getByAjax();
	myajax.init(null,"get",true);
	myajax.get("/networkforum/user/visit_user.do?targetId="+targetId,initBack);
	myajax = null;

	pageHandle(targetId);
}
function initBack(d){
	//var data = eval("("+d+")");
	var data = toJson(d);
	//说说信息展示
	activeInfo().addNode(data.noticeInfo);
	//博客信息展示
	//listInit(data.articleInfo);
	articlePageing(data.articleInfo);
	pictureInfo(data.pictureInfo);
	visitorInfo(data.visitors);
	userInfo(data.userInfo);
}
function articlePageing(data){
	listInit(data.slice(0,10));

	paging.page({
		size:10,
		total:Math.ceil(data.length/10),
		ajaxLoad:false,
		previou:document.getElementById("previouPage2"),
		next:document.getElementById("nextPage2"),
		current:document.getElementById("currentPage2"),
		max:document.getElementById("totalPage2"),
		callBack:function(d){
			var mcinfo = document.getElementById("listInner");
			mcinfo.innerHTML = "";
			listInit(d);
		},
	});
}
function pageHandle(targetId){
	//好友分页
	var myajax = getByAjax();
	myajax.init(null,"get",true);
	myajax.get("/networkforum/article/count_size.do?moduleName=动态",function(d){
		paging.page({
			size:10,
			total:Math.ceil(d/10),
			url:"/networkforum/visit/load_dongtai.do?targetId="+targetId,
			previou:document.getElementById("previouPage1"),
			next:document.getElementById("nextPage1"),
			current:document.getElementById("currentPage1"),
			max:document.getElementById("totalPage1"),
			callBack:function(d){
				var mcinfo = document.getElementById("mcinfo");
				mcinfo.innerHTML = "";
				activeInfo().addNode(d);
			},
		});
	});
	myajax = null;
	
}
function userInfo(data){
	document.getElementById("userPhoto").src=data.userPhoto;
	document.getElementById("userName").innerHTML="昵称： "+data.userName;
	document.getElementById("userSex").innerHTML="性别： "+data.userSex;
	document.getElementById("userScore").innerHTML="积分： "+data.userScore;
	document.getElementById("userHover").innerHTML="爱好： "+data.userHover;
	document.getElementById("userEmail").innerHTML="邮箱： "+data.userEmail;
	document.getElementById("userPlace").innerHTML="地区： "+data.userPlace;
	document.getElementById("lastLoginTime").innerHTML="最后登录时间： "+data.lastLoginTime;
}
function visitorInfo(data){
	var vp = {
		userPhoto:{
			param:{id:"userPhoto"},
			bind:{userId:"userId"}
		},
		userName:{
			param:{id:"userName"},
		},
		visitTime:{
			param:{id:"visitTime"}
		}
	}
	//	page.view('articleInner',article,articleOption);
	page.view("visitInner",data,vp,true);
	vp = null;
}
function pictureInfo(data){
	//当该用户有相册时才展示相册信息

	
	if(data.length>0){
		var pgmain = document.getElementById("pgmain");
		var notice = document.getElementById("notice");
		pgmain.removeChild(notice);
		//相册列表展示
		var frag = document.createDocumentFragment();
		for(var i =0;i<data.length;i++){
			var d = data[i];

			var li = document.createElement("li");
			var img = document.createElement("img");
			//img.src = d.image;
			reloadPicture(img,d.image);
			img.ispublic = d.ispublic;
			img.groupId = d.groupId;
			img.name = d.name;
			img.title = "名称："+d.name+"\n总共："+d.number+"\n状态："+d.ispublic;
			li.appendChild(img);
			frag.appendChild(li);
			img.onclick = function(event){
				var e = event || window.event;
				var target = e.target || e.srcElement;
				if(target.ispublic == "加密"){
					alert("该相册未公开!");
					return;
				}
				location = "/networkforum/visit/visit_picture.do?index=0&isgroup=true&targetId="+target.groupId;
			}
		}
		pgmain.appendChild(frag);
	}
	//如果相册超过可视区域，则为相册添加滚动效果
	if(data.length>5){
		//跑马灯效果设置
		scorl = SCROL();
		scorl.init(pgmain,2,30);
		scorl.scrol();
	}
}
</script>
</head>

<body>
	<input id="targetId" type="text" disabled="disabled" value=${targetId}/>
	<iframe id="tnav" class="tnav" src = "/networkforum/pages/user/user_header.html"></iframe>
    <header class="header">
    	<label>xunxun</label>
        <label>今天有一天天气那什么</label>
    </header>
    <section class="userBasic userInfo">
    	<header class="userInfoHeader">
    		资料
    	</header>
    	<div class="alpha5"></div>
    	<section class="basicInner">
	   		<img id="userPhoto" src="/networkforum/images/left1.jpg"/>
    		<section class="basicInfo">
    			<!-- <label id="userScore">积分：(0)</label>
			    <label id="userFriend">好友：(0)</label>
       			<label id="visitTimes">访问次数：(0)</label> -->
    		</section>
    		<div class="clear"></div>
    		<ul id="bInnerUl">
    			<li>
		    		<label id="userName">昵称： xunxun</label>
    			</li>
    			<li>
		    		<label id="userSex">性别： 男</label>
    			</li>
    			<li>
		    		<label id="userScore">积分： </label>
    			</li>
    			<li>
		    		<label id="userHover">爱好： </label>
    			</li>
    			<li>
		    		<label id="userEmail">邮箱： 649658707@qq.com</label>
    			</li>
    			<li>
		    		<label id="userPlace">地区： xunxun</label>
    			</li>
    			<li>
		    		<label id="lastLoginTime">上次登录时间：2012-12-12 12：12：12</label>
    			</li>
    		</ul>
    		<span onclick="leaveMessage('/networkforum/pages/message/message_main.html',window.document.body);">留言</span>
    	</section>
    </section>
    <section class="userNotice userInfo">
    	<header class="userInfoHeader">
        	说说
        </header>
		<div class="alpha5"></div>
        <section class="noticeInner infoInner" id="mcinfo">
        
        </section>
        <div class="paging" id="paging">
   			<div class="clear"></div>
	   		<span id="previouPage1" style="cursor: pointer;">上一页</span>
	   		<input id="currentPage1" type="text" value = "1"/>	
	   		<span id="nextPage1" style="cursor: pointer;">下一页</span>
	   		<span id="totalPage1">共 1 页</span>
	   	</div>
    </section>
    <section class="userVisit userInfo">
    	<header class="userInfoHeader">
        	访客
        </header>
        <div class="alpha5"></div>
		<section class="visitInner">
       		<ul id="visitInner">
       			<li style="display:none;">
       				<img id="userPhoto" src="../../images/left1.jpg"/>
       				<span id="userName">xunxun</span>
       				<span id="visitTime">2012-12-21 12:12:12</span>
       			</li>
            </ul>
        </section>    	
    </section>
    <section class="userArticle userInfo">
    	<header class="userInfoHeader">
        	热门博客
        	<span>更多</span>
        </header>
        <div class="alpha5"></div>
		<section class="articleInner infoInner">
       		<ul id="listInner">
            </ul>
        </section>    	
        <div class="paging" id="paging">
   			<div class="clear"></div>
	   		<span id="previouPage2" style="cursor: pointer;">上一页</span>
	   		<input id="currentPage2" type="text" value = "1"/>	
	   		<span id="nextPage2" style="cursor: pointer;">下一页</span>
	   		<span id="totalPage2">共 1 页</span>
	   	</div>
    </section>
    <section class="userPicture userInfo" style="min-height:270px;">
        <header class="userInfoHeader">
        	相册
        </header>
        <div class="alpha5"></div>
		    <img onclick="scorllHandle(-180);" class="pleft" src="/networkforum/images/pleft1.jpg"/>
			<section class="pictureInner infoInner">
        	<ul class="pgmain" id="pgmain">
				<label id="notice" style = "float:left;width:65%;height: 100%;display:block;font-size:24px;text-align: center;">暂无相册</label>
            </ul>
        	</section>
            <img onclick="scorllHandle(180)" class="pright" src="/networkforum/images/pright1.jpg"/>                    
        <div class="clear"></div>
    </section>
    <iframe class="footer" src="/networkforum/pages/footer.html"></iframe>
</body>
<script type="text/javascript" src="/networkforum/js/myajax.js"></script>
<script type="text/javascript" src="/networkforum/js/article_main.js"></script>
<script type="text/javascript" src="/networkforum/js/base.js"></script>
<script type="text/javascript" src="/networkforum/js/picture_main.js"></script>
<script type="text/javascript" src="/networkforum/js/view.js"></script>
<script type="text/javascript" src="/networkforum/js/pageing.js"></script>
</html>
